package Homework;

import java.io.*;
import java.nio.charset.StandardCharsets;

public class OSWDemo {
    public static void main(String[] args) throws IOException {

        FileOutputStream fos=new FileOutputStream("t4.txt");
        OutputStreamWriter osw = new OutputStreamWriter(fos, StandardCharsets.UTF_8);
        osw.write("你好我叫小帅，");
        osw.write("大家好我是大壮");
        System.out.println("写入完毕");
        osw.close();



        FileInputStream fis=new FileInputStream("t4.txt");
        InputStreamReader isr=new InputStreamReader(fis,StandardCharsets.UTF_8);
        int i;
        while ((i=isr.read())!=-1){
            System.out.print((char)i);
        }
        System.out.println("输出完毕！");
        isr.close();
    }
}
